<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layuiAdmin 控制台主页一</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{{ADMIN_PATH}}layui/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="{{ADMIN_PATH}}layui/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-row layui-col-space15">
                <div class="layui-card-body">
                <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <div class="layui-btn-group form_quick_date">
                                <a class="layui-btn layui-btn-primary" data-type="1"
                                   onclick="form_do_set_day(1,null,null)">今天</a>
                                <a class="layui-btn layui-btn-primary" data-type="2"
                                   onclick="form_do_set_day(2,null,null)">昨天</a>
                                <a class="layui-btn layui-btn-primary" data-type="3"
                                   onclick="form_do_set_day(3,null,null)">本周</a>
                                <a class="layui-btn layui-btn-primary" data-type="4"
                                   onclick="form_do_set_day(4,null,null)">上周</a>
                                <a class="layui-btn layui-btn-primary" data-type="5"
                                   onclick="form_do_set_day(5,null,null)">本月</a>
                                <a class="layui-btn layui-btn-primary" data-type="6"
                                   onclick="form_do_set_day(6,null,null)">上月</a>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label layui-hide-md">开始日期</label>
                            <div class="layui-input-inline" style="width:100px;">
                                <input type="text" class="layui-input" id="search_start_date" name="start_date"
                                       autocomplete="off"
                                       format="date" value="{{$begin_month}}" placeholder="开始日期">
                            </div>
                            <div class="layui-form-mid">
                                -
                            </div>
                            <div class="layui-input-inline" style="width:100px;">
                                <input type="text" class="layui-input" id="search_end_date" name="end_date"
                                       autocomplete="off"
                                       format="date" value="{{$end_month}}" placeholder="结束日期">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="LAY-app-contlist-search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                            </button>

                        </div>
                    </div>
                </div>
                </div>


                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">月统计</div>
                        <div class="layui-card-body">

                            <div class=" layadmin-backlog">
                                <div carousel-item>
                                    <ul class="layui-row layui-col-space10">
                                        <li class="layui-col-xs3">
                                            <a href="javascript:;" class="layadmin-backlog-body">
                                                <h3>月总订单数</h3>
                                                <p><cite>{{$orderSum}}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs3">
                                            <a href="javascript:;" class="layadmin-backlog-body">
                                                <h3>月录单金额</h3>
                                                <p><cite>{{$orderSaleMoney}}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs3">
                                            <a href="javascript:;" class="layadmin-backlog-body">
                                                <h3>月充值金额</h3>
                                                <p><cite>{{$orderRanceMoney}}</cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs3">
                                            <a href="javascript:;" class="layadmin-backlog-body">
                                                <h3>月退款金额</h3>
                                                <p><cite>{{$backMoney}}</cite></p>
                                            </a>
                                        </li>

                                    </ul>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">总订单汇总</div>
                        <div class="layui-card-body">
                    <table class="layui-table" id="main_table"  lay-filter="main_table"></table>
                        </div></div>
                </div>




            </div>
        </div>



    </div>
</div>
<link rel="stylesheet" href="{{ADMIN_PATH}}jqueryui/jquery-ui.css">
<script src="{{ADMIN_PATH}}/lib/jquery-2.1.0.js"></script>
<script src="{{ADMIN_PATH}}/lib/jquery-migrate-1.2.1.min.js"></script>
<script src="{{ADMIN_PATH}}jqueryui/jquery-ui-1.10.3.min.js"></script>
<!-- 勿删，这里是显示帮助说明文，会调用系统菜单中的说明文档 -->
<div id="page_tip"></div>
<script src="{{ADMIN_PATH}}layui/layuiadmin/layui/layui.js?{{time()}}"></script>
<script src="{{ADMIN_PATH}}js/admin.common.js?{{time()}}"></script>
<script>
    // ==========================  公共变量区  ===========================================
    var index_url = '{{url('admin/console')}}';
    //表格id
    var main_table_id = 'main_table';
    //搜索区的表单form id
    var search_form_id = 'search_form';
    //初始化后的表格对象
    var main_table;
    // ==============================  业务处理  ==============================================
    layui.config({
        base: '{{ADMIN_PATH}}layui/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','laydate', 'table'], function() {

        //========================================== layui引用区 ==========================================
        //var $ = layui.$,
        var $ = layui.jquery,
            table = layui.table
            , laydate = layui.laydate
            , form = layui.form
            , element = layui.element
        ;

        // ==============================  业务区  =========================================
        //表格默认排序字段
        var table_sort = 'add_time';
        var table_order = 'desc';

        main_table = table.render({
            elem: '#' + main_table_id
            , url: index_url //异步数据接口
            , method: 'post' //接口http请求类型
            //, headers: {token: '123456'} //接口的请求头
            , limit: 50 //每页显示的条数
            , limits: 50//	每页条数的选择项
            , initSort: { //初始化时的排序,如果不设的话，将无法标记表头的排序状态
                field: table_sort
                , type: table_order
            }
            , where: {sort: table_sort, order: table_order,start_date:'{{$begin_month}}',end_date:'{{$end_month}}'}
            , loading: true //显示加载
            , text: '查询无数据' //空数据时的异常提示
            , page: true //开启分页
            , cols: [[
                {title: 'ID', field: 'id', width: 65, sort: true}
                , {field: 'add_time', title: '充值时间', width: 130, sort: true, templet: layui_table_time_tpl_3}
                , {
                    title: '订单类型', field: 'order_type', width: 95, templet: function (d) {
                        if (d.order_type == 1) {
                            return '产品订单';
                        } else {
                            return '充值订单';
                        }
                    }
                }
                , {title: '总额', field: 'all_amount', width: 95}
                , {title: '实付', field: 'paid_amount', width: 95}
                , {title: '代付/赠送', field: 'collected_amount', width: 95}
                , {
                    title: '充值会员', field: 'pay_username', width: 95, templet: function (d) {
                        if (d.pay_username == null) {
                            return '系统支付';
                        } else {
                            return d.pay_username;
                        }
                    }
                }
                , {title: '微信号', field: 'wx_no', width: 95}
                , {title: '销售员', field: 'sale_name', width: 95}
                , {title: '粉丝类型', field: 'add_fen_type', width: 95}
                , {
                    title: '本月粉丝', field: 'add_fen_month', width: 120, templet: function (d) {
                        if (d.add_fen_month == 1) {
                            return '本月粉丝';
                        } else {
                            return '非本月粉丝';
                        }
                    }
                }
                , {
                    title: '付款方式', field: 'pt_name', width: 120, templet: function (d) {
                        if (d.pt_name == 1) {
                            return '全款';
                        } else {
                            return '到付';
                        }
                    }
                }

                , {
                    field: 'apply_status', title: '审核状态', width: 120, fixed: 'right', templet: function (d) {
                        if (d.apply_status == '0') {
                            return '审核失败,原因:' + d.apply_error_msg;
                        }
                        if (d.apply_status == '10') {
                            return '<span style="color:blue">等待审核</span>';
                        }
                        if (d.apply_status == '20') {
                            return '<span style="color:green">审核通过</span>';
                        }
                        if (d.apply_status == '30') {
                            return '<span style="color:red">已退款</span>';
                        }
                    }
                }

            ]]
            , done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                if (res.status != 200) {
                    show_error(res.message);
                }
                if (count == 0) {
                    layer.msg('暂无相关数据');
                }
            }
        });
        form.on('submit(LAY-app-contlist-search)', function(data){

            var field = data.field;
            console.log(field);
            location.href=index_url+'?start_date='+field.start_date+'&end_date='+field.end_date;
            //
            // //执行重载
            // table.reload('main_table', {
            //     where: field
            // });
        });
        var insStart = laydate.render({
            elem: '#search_start_date'
            , type: 'date'
            , format: 'yyyy-MM-dd'
            //, min: 0
            , done: function (value, date) {
                //更新结束日期的最小日期
                insEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                insEnd.config.elem[0].focus();
            }
        });

        //结束日期
        var insEnd = laydate.render({
            elem: '#search_end_date'
            , type: 'date'
            , format: 'yyyy-MM-dd'
            //, min: 0
            , done: function (value, date) {
                //更新开始日期的最大日期
                insStart.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });
    });
</script>
</body>
</html>



